package com.bharatonjava.hospital.dao.rowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.bharatonjava.hospital.domain.Address;
import com.bharatonjava.hospital.domain.Patient;
import com.bharatonjava.hospital.dto.SearchDto;

public class SearchDtoRowMapper implements RowMapper<SearchDto>{

	@Override
	public SearchDto mapRow(ResultSet rs, int rowNum) throws SQLException {
		SearchDto dto = new SearchDto();
		Patient p = new Patient();
		p.setPatientId(rs.getLong("patient_id"));
		p.setFirstName(rs.getString("patient_first_name"));
		p.setMiddleName(rs.getString("patient_middle_name"));
		p.setLastName(rs.getString("patient_last_name"));
		p.setGender(rs.getString("patient_gender"));
		p.setDob(rs.getString("patient_dob"));
		Address a = new Address();
		a.setBuilding(rs.getString("building"));
		a.setStreet(rs.getString("street"));
		dto.setPatient(p);
		dto.setAddress(a);
		return dto;
	}

}
